<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>箱子明细信息</title>
		<script type="text/javascript">
		  	function initPrinter(item) {
		printBoxCode = item;
		var indexLength = getPrinterCount();
		var tempString = "";
		for ( var i = 0; i < indexLength; i++) {
			var name = getPrinterName(i);
			tempString += "<option value='"+name+"'>" + name + "</option>";
		}
		$("#printerBody").html(tempString);
	}

	//获得打印机的个数
	function getPrinterCount() {
		LODOP = getLodop(document.getElementById('LODOP_OB'), document
				.getElementById('LODOP_EM'));
		return LODOP.GET_PRINTER_COUNT();
	};

	//根据打印机序号获得打印机名称
	function getPrinterName(iPrinterNO) {
		LODOP = getLodop(document.getElementById('LODOP_OB'), document
				.getElementById('LODOP_EM'));
		return LODOP.GET_PRINTER_NAME(iPrinterNO);
	};
	
	function printExpressBoxCode() {
	   var printName=$("#printerBody").val();
		LODOP = getLodop(document.getElementById('LODOP_OB'), document
				.getElementById('LODOP_EM'));
		LODOP.PRINT_INIT(printBoxCode);
		LODOP.SET_PRINT_PAGESIZE(1, 600, 320, "");
		LODOP.ADD_PRINT_BARCODE(25, 10, 200, 45, "128A", printBoxCode);
		if (LODOP.SET_PRINTER_INDEXA(printName)) {
			LODOP.PRINT();
		}
	}
		
		</script>
	</head>

	<body>
		<table id="contentTable"
			class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>
						编号
					</th>
					<th>
						箱子数量
					</th>
					<th>
						生成日期
					</th>
					<th>
						处理日期
					</th>
					<th>
						订单数量
					</th>
					<th>
						商品数量
					</th>
					<th>
						商品种类
					</th>
					<th>
						类型
					</th>
					<th>
						操作人
					</th>
					
				</tr>
			</thead>
			<tbody>
				
					<tr>
						<td>
							${obj.backupTaskCode }
						</td>
						<td>
							${obj.boxQty }
						</td>
						<td>
							${obj.createDate }
						</td>
						<td>
							${obj.updateDate }
						</td>
						<td>
							${obj.ordenoQty }
						</td>
						<td>
							${obj.skuQty }
						</td>
						<td>
							${obj.skuType }
						</td>
						<td>
							<c:if test="${obj.type eq 'single' }">
							     单件
							</c:if>
							<c:if test="${obj.type eq 'multiple' }">
							  多件
							</c:if>
						</td>
						<td>
							${obj.username }
						</td>
						
					</tr>
			
			</tbody>
		</table>
		<a class="btn"
			href="${ctx}/shippedBox/exportExcel/${obj.batchCode}">全部导出</a>
		<div class="tabbable">
			<ul class="nav nav-tabs">
				<c:set var="index" value="0"></c:set>
				<c:forEach items="${maps }" var="map">
				
					<c:if test="${index eq '0' }">
					
						<li class="active">
 <a href="#selextPrinter" role="button" data-toggle="modal"
									  class="btn btn-inverse"
									 onclick="initPrinter('${map.key}')">打印箱子编码</a>
							<a href="#${map.key }" data-toggle="tab"><span
								id="fold${map.key }">${map.key}</span></a>
								
						</li>
					</c:if>

					<c:if test="${index eq '1' }">
					
						<li class="">
						 <a href="#selextPrinter" role="button" data-toggle="modal"
									  class="btn btn-inverse"
									 onclick="initPrinter('${map.key}')">打印箱子编码</a>
							<a href="#${map.key }" data-toggle="tab"><span
								id="fold${map.key }">${map.key}</span> </a>
						</li>
					</c:if>
					<c:set var="index" value="1"></c:set>
				</c:forEach>
			</ul>

			<div class="tab-content">
				<c:set var="index" value="0"></c:set>
				<c:forEach items="${maps }" var="map">
				
					<c:if test="${index eq '0' }">
										
						<div class="tab-pane active" id="${map.key }">
							
							<table
								class="table table-striped table-bshippedOrdered table-condensed"
								id="fold${map.key }_tab">
								<thead>
									<tr>
										<th>
											商品编码
										</th>
									
										<th>
											数量
										</th>
										
										
										
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${map.value }" var="mapObject">
										<tr>
											<td>
												${mapObject.skuId }
											</td>
											<td>
												${mapObject.realQty }
											</td>
											
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>

					</c:if>

					<c:if test="${index eq '1' }">
											
						<div class="tab-pane" id="${map.key }">
							<table
								class="table table-striped table-bshippedOrdered table-condensed"
								id="fold${map.key }_tab">
								<thead>
									<tr>
										<th>
											商品编码
										</th>
										
										<th>
											数量
										</th>
										
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${map.value }" var="mapObject">
										<tr>
											<td>
												${mapObject.skuId }
											</td>
											<td>
												${mapObject.realQty }
											</td>
											
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>

					</c:if>
					<c:set var="index" value="1"></c:set>
				</c:forEach>

			</div>
		</div>
		
		<div style="display: none; width: 1000" class="modal hide fade"
			tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
			aria-hidden="true" id="selextPrinter">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">
					×
				</button>
				<h3 id="printerNumber">
					选择打印机
				</h3>
			</div>
			<div class="modal-body">
				<select id="printerBody" name="printerBody">
				</select>
			</div>
			<div class="modal-footer">

				<button class="btn" data-dismiss="modal" aria-hidden="true"
					id="printer" onclick="printExpressBoxCode()">
					开始打印
				</button>

				<button class="btn" data-dismiss="modal" aria-hidden="true">
					Close
				</button>
			</div>
		</div>
	</body>
</html>
